slowfandomcom-20200216-history
Help:Magic Words
This article is sourced from Wikipedia's Magic Words article, it was tricky to find, so I copied it for quick and easy reference. Magic words (which include parser functions, variables and behavior switches) are features of wikitext that enable various instructions to be given to the software (for example, to suppress or position the table of contents), or else serve to produce variable output, as is often required in templates. A quick reference for magic words can be found on this page. For more complete and updated documentation, refer to the following pages on the MediaWiki site: *'mw:Help:Magic words' for all standard magic words, including the "standard" parser functions *'mw:Help:Extension:ParserFunctions' for some additional parser functions, including conditional expressions General information There are three types of magic words: *'Behavior switches:' uppercase words surrounded by double underscores, e.g. , or keywords using parser function syntax *'Variables:' uppercase words surrounded by double braces, e.g. (thus resembling ) *'Parser functions:' keywords (some beginning #) in double braces with parameters after a colon, e.g. Some magic words are case-insensitive, but not all. White space is stripped from the start and end of keywords and parameters, as in template syntax. Page-dependent magic words will affect or return data about the current page, even if the word is added through a transcluded template or included system message. It is possible to parser functions and variables in the same way that templates are substituted (using the subst: keyword). This causes their current value (as evaluated at the time of substitution) to be written into the wikitext. Behavior switches For documentation, refer to the Behavior Switches section of the MediaWiki page. * (can appear anywhere in the wikitext; suppresses the table of contents) *__FORCETOC__ (can appear anywhere in the wikitext; makes a table of contents appear in its normal position above the first header) *__TOC__ (places a table of contents at the word's position) *__NOEDITSECTION__ (hides the section "edit" links beside all headings on the page) (use tags to hide the edit link for one header only) *__NEWSECTIONLINK__ (adds a "+" link for adding a new section on a non-"Talk" page) *__NONEWSECTIONLINK__ (removes the "+" link on "Talk" pages) *__NOGALLERY__ (on a category page, replaces thumbnails with normal links) * (on a category page, makes it a hidden category) *__INDEX__ (tells search engines to index the page) *__NOINDEX__ (tells search engines not to index the page) *__STATICREDIRECT__ (On redirect pages, don't allow MediaWiki to automatically update the link when someone moves a page and checks "Update any redirects that point to the original title", also used to tell interwikibots that this redirect might be seen as an article) * (changes the displayed form of the page title) * (sets a default category sort key) Variables For documentation, refer to the Variables section of the MediaWiki page. * ( including namespace) * (page title excluding namespace) * (page title excluding current and namespace - effectively the parent page without the namespace.) * (subpage part of title) * , (associated non-talk page) * (associated talk page) * (namespace of current page) * , (associated non-talk namespace) * (associated talk namespace) * , etc. (equivalents encoded for use in MediaWiki URLs) The above can all take a parameter, to operate on a page other than the current page. * ( ) * ( ) * ( ) * ( ) * (current MediaWiki version) * (latest revision to current page) * , , , , , (date, time, editor at last edit) * , , , , , , , , , , , (current date/time variables) * etc. (as above, based on site's local time) * , , , , , , , (statistics on English Wikipedia; add :R to return numbers without commas) Parser functions These are fully documented at the Meta magic words page or ParserFunctions Extension documentation unless otherwise stated. Metadata * (unique page identifier number) * (size of page in bytes) * (protection level for given action on the current page) * (number of pages in the given ) * (number of users in a specific ) Add |R to return numbers without commas. Formatting * (convert to lower case) * (convert first character to lower case) * (convert to upper case) * (convert first character to upper case) * (format a number with comma separators; add |R to unformat a number) * (formats a date according to user preferences; a default can be given as an optional case-sensitive second parameter for users without date preference; can convert a date from an existing format to any of dmy, mdy, ymd or ISO 8601 formats, with the user's preference overriding the specified format) * , (pad with zeros to the right or left; an alternative padding string can be given as a third parameter; the alternative padding string may be truncated if its length does not evenly divide the required number of characters) * (produces alternative text according to whether n'' is greater than 1) * (for date/time formatting; also #timel for local time. Covered at the extension documentation page.) * (produces alternative text according to the gender specified by the given user in his/her preferences) * (equivalent to an HTML tag or pair of tags; can be used for nesting references) Paths * , (relative path to the title) * , (absolute path to the title, without a protocol prefix) * , (absolute path to the title, with a protocol prefix) * (absolute URL to a media file) * (input encoded for use in URLs) * (input encoded for use in URL section anchors) * (name for the with index ''n; use for the equivalent encoded for MediaWiki URLs) * (converts a relative file path to absolute; see the extension documentation) * (splits title into parts; see the extension documentation) Conditional expressions These are covered at the extension documentation page. Some parameters are optional. * (evaluates the given expression; see ) * (selects one of two values based on whether the test string is empty) * (selects one of two values based on whether the test strings are equal – numerically if applicable) * (selects value based on whether the test string generates a parser error) * (selects value based on evaluation of expression) * (selects value depending on whether a page title exists) * (provides alternatives based on the value of the test string) Note that with #if: expressions, a variable like } always requires a final pipe: }. If it is absent, then whenever the parameter 1 is absent, instead of leaving the field blank the software will use the actual text } and the field will never be empty. For the use of these functions in tables, see Conditional tables. Category:Features